import random

from selenium import  webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.keys import Keys

op = webdriver.ChromeOptions()
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options = op)

driver.get(r"http://wwww.baidu.com")
search =  driver.find_element(By.CSS_SELECTOR,"#kw")
search.send_keys("自动化")
sleep(2)
number = random.randint(1,10)
print("随机数：",number)
for i in range(number):
    search.send_keys(Keys.DOWN)
search.send_keys(Keys.ENTER)

assert "自动化"  in driver.title
sleep(3)
driver.quit()